Repository navigation
London | 26-Sep-ITP | Frumentius Tesfay | Sprint 2 | Coursework/sprint 3 practice tdd - #1713
Open
Frumentius-Rev wants to merge 7 commits into
Open
Frumentius-Rev wants to merge 7 commits into
Frumentius-Rev wants to merge 7 commits into
Conversation
hackertainment
left a comment
There was a problem hiding this comment.
Thank you for your coursework. Please keep it up.
Comment on lines
13
to
18
| test("should count multiple occurrences of a character", () => { | ||
| const str = "aaaaa"; | ||
| const char = "a"; | ||
| const count = countChar(str, char); | ||
| expect(count).toEqual(5); | ||
| }); |
There was a problem hiding this comment.
This is a special case of str where it is all the char to count. Would it still count correctly if the char just exists in some part of the str?
Comment on lines
+26
to
+29
| test("should return 0 when character does not occur", () => { | ||
| const count = countChar("hello", "z"); | ||
| expect(count).toEqual(0); | ||
| }); |
There was a problem hiding this comment.
There is a special str that would give 0 anyway. Please add that test case as well. Thank you.
Comment on lines
43
to
46
| // Case: Handle negative count: | ||
| // Given a target string `str` and a negative integer `count`, | ||
| // When the repeatStr function is called with these inputs, | ||
| // Then it should throw an error, as negative counts are not valid. |
There was a problem hiding this comment.
Please add test case for this requirement as well. Thank you.
Comment on lines
12
to
+31
| test("should repeat the string count times", () => { | ||
| const str = "hello"; | ||
| const count = 3; | ||
| const repeatedStr = repeatStr(str, count); | ||
| expect(repeatedStr).toEqual("hellohellohello"); | ||
| }); | ||
|
|
||
| test("should return the original string when count is 1", () => { | ||
| const str = "hello"; | ||
| const count = 1; | ||
| const repeatedStr = repeatStr(str, count); | ||
| expect(repeatedStr).toEqual("hello"); | ||
| }); | ||
|
|
||
| test("should return an empty string when count is 0", () => { | ||
| const str = "hello"; | ||
| const count = 0; | ||
| const repeatedStr = repeatStr(str, count); | ||
| expect(repeatedStr).toEqual(""); | ||
| }); |
There was a problem hiding this comment.
Your test cases are correct. Just for you to think a little bit more, besides const str = "hello", what special string should also be added to each of the test cases?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Task code
CYF-1060
Changelist
Implemented countChar and repeat Str with tests.